<?php
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";
require_once "config.php";
require_once "Includes/conexion.class.php";

$err=0;
//'****************************************
//' N I V E L    1
//'****************************************
$strSql= "select * from solotb_nivel1 order by des";
SoloFun_ExecSql ($strSql,$arrModu);
//   'response.Write(ret)
if ($_REQUEST["CmbModulo"] != "") {
    $strid1=$_REQUEST["CmbModulo"];
}else {
    $strid1=$arrModu[0][0];
}

//'****************************************
//' N I V E L    2
//'****************************************

//'   If Request("CmbModulo")<>"" then   
//'      strSql=strSql & " where id1=" & Request("CmbModulo")
//'   else
//'      strSql=strSql & " where id1=" & Modulo1    	  
//'   end if	  

$strSql="select * from solotb_nivel2 left join solotb_usuario on co_supervisor = nu_usua";
$strSql .= " where id1=" . $strid1;
$strSql .= " order by des";


$ret=SoloFun_ExecSql ($strSql,$arrData);
//'   If request("CmbModulo")<>"" then
//'	     strSql=strSql & " having id1=" & Request("CmbModulo")
//'   else
//'	     strSql=strSql & " having id1=" & Modulo1
//'   end if

$strSql="select (max(id2)+1) as id  from solotb_nivel2";
$strSql .= " where id1=" . $strid1;
//'   response.write strsql
SoloFun_ExecSql ($strSql,$ArrMaxId);


$MaxId=$ArrMaxId[0][0];
if (is_null($MaxId)) {
    $MaxId=($strid1*100)+1;
}
//    'response.write "este es el maximo: "& MaxId & "--------" & strSQL
//	'response.end

//Tecnicos
//$soloSQL2 = "select nu_usua, no_usua from solotb_usuario where co_perf = (select valor from solotb_parametros where descripcion = 'Id Supervisor')";
$soloSQL2 = "select nu_usua, no_usua from solotb_usuario where co_perf in (33,36)";
soloFun_ExecSQL ($soloSQL2,$SoloArrSupervisor);
//printArray($SoloArrSoporte);
$StrCboSupervisor = SoloFun_CargaCombo($SoloArrSupervisor,"CboSupervisor","",""," style='width: 180px' class='SoloStyle_Texto' ", "B");
?>

<html>
    <head>
        <title>Documentacion</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link rel="stylesheet" href="SoloStyles/Solostyles.css" type="text/css">
        <SCRIPT type="text/JavaScript" src="Includes/Solofun_generales.js"></SCRIPT></head>

    <body topmargin=0 leftmargin=0>
        <!-- Include File="includes/trn_header.asp" -->
        <p align="center" class="SoloStyle_TituloPaginas">Tabla de Departamentos</p>
        <form name="frmIngreso" action="trn_GrabaCategoria.php" method="POST">
            <table border="0" width="50%" align="center">
                <tr>
                    <td class="SoloStyle_Etiqueta" ><strong>Subsecretar&iacute;a/Dir. Provincial </strong></td>
                    <td ><select name="CmbModulo" class="SoloStyle_Texto" OnChange="document.frmIngreso.action='trn_Categorias.php';document.frmIngreso.submit();" style="width:185">
                            <?php
                            for ($i=0; $i < count($arrModu);$i++) {
                                $ind=$arrModu[$i][0];
                                $jnd=$_REQUEST["CmbModulo"];
                                if ($jnd==$ind) {
                                    echo "<option value='" . $ind . "' SELECTED >" . $arrModu[$i][1] . "</option>";
                                }else {
                                    echo "<option value='" . $ind . "'>" . $arrModu[$i][1] . "</option>";
                                }
                            }
                            ?>
                        </select></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">C&oacute;digo</td>
                    <td><input name="hidId1" type="text" class="SoloStyle_Texto" value="<?php echo $MaxId; ?>" size="40" readonly></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">Nuevo Departamento</td>
                    <td><input name="ATxtDesc" type="text" class="SoloStyle_Texto" size="40" maxlength="50"></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">Supervisor</td>
                    <td><?php echo $StrCboSupervisor;?></td>
                </tr>
            </table>
            <br><center>
                <input type="button" name="CmdGrabar" value="Grabar" class="SoloStyle_Boton" onClick="SoloFun_Submit(frmIngreso)"></center>
            <input type="hidden" name="opc" value="G">
        </form>
        <table width="50%" border="0" align="center">
            <tr class="SoloStyle_Etiqueta">
                <td class="texto">Departamento</td>
                <td class="texto">Supervisor</td>
                <td class="texto" width="20%">Acci&oacute;n</td>
            </tr>
            <?php for ($i=0;$i < count($arrData);$i++) {
                $clase = "SoloStyle_Grid";
                if($i%2 > 0)
                    $clase = "SoloStyle_Texto";
                ?>

            <tr class="<?php echo $clase;?>">
                <td><?php echo $arrData[$i][2];?></td>
                <td><?php echo $arrData[$i][6];?></td>
                <td><a href="trn_GrabaCategoria.php?id1=<?php echo $arrData[$i][0];?>&id2=<?php echo $arrData[$i][1];?>&ds1=<?php echo $arrData[$i][2];?>&ds2=<?php echo $arrData[$i][3];?>&opc=M&CboSupervisor=<?php echo $arrData[$i][3];?>">
                        <img src='iconos/soloico_modificar.gif' alt='Modificar' width="23" height="19" border='0' style='cursor:hand'>
                    </a><a href="#" OnClick="Comprobar('trn_GrabaCategoria.php?id1=<?php echo $arrData[$i][0];?>&id2=<?php echo $arrData[$i][1];?>&ds1=<?php echo $arrData[$i][2];?>&ds2=<?php echo $arrData[$i][3];?>&opc=E')">
                        <img src='iconos/soloico_eliminar.gif' alt='Borrar Campos' width="23" height="19" border='0' style='cursor:hand'>
                    </a>   </td>
            </tr>
                <?php }?>
        </table>
    </body>
</html>
<!--#include file="Includes/soloFun_ShowMessages.asp"-->

<SCRIPT type="text/javascript" src="PHPMailer/fun_generales.js"></SCRIPT>

<script type="text/javascript">

    function Comprobar(pagina){
        //    conf = msgbox("Confirma Eliminar", VBOKCANCEL + VBQUESTION,"SoloPortal")
        var conf = confirm("Confirma Eliminar");
        if (conf)
            window.location.href = pagina

    }

</script>